<?php

namespace app\model;
use think\Model;

class Video extends Model
{
    public static function getInfo($file)
    {

        if(isLinux()){
            // 通过Shell命令调用FFprobe工具获取视频信息
            $command = "ffprobe -v error -select_streams v:0 -show_entries stream=duration -of csv=s=x:p=0 " . $file;
            $info = shell_exec($command);

// 解析获取到的视频信息
            $infoArray = explode("x", $info);
            $duration = $infoArray[0];
        }else{
            //获得时长，单位秒
            $ffprobe = \FFMpeg\FFProbe::create();
            $duration = $ffprobe->format($file)->get('duration', 0);//这是获得的时长
        }
        return (int)$duration;
    }



}